package com.hzit.handler;

import com.hzit.except.BusinessException;
import com.hzit.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 类名：
 * 作者：WF
 * 功能：全局异常处理器
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

	@ExceptionHandler(BusinessException.class)
	public R handlerBusinessException(BusinessException e){
		System.out.println("出现了异常，" + e);
		return R.error().code(e.getCode()).message(e.getMessage());
	}

}
